<?php
class ArticlesTagsController extends AppController {

	var $name = 'ArticlesTags';
	var $helpers = array('Html', 'Form');

	function add() {
		if (!empty($this->data)) {
			$this->ArticlesTag->create();
			if ($this->ArticlesTag->save($this->data)) {
				$this->Session->setFlash(sprintf(__('The %s has been add.', true), __('Tag',true)));
				$this->redirect(array('action'=>'index'));
			} else {
				$this->Session->setFlash(__('Please correct errors below.', true));
			}
		}
		$articles = $this->ArticlesTag->Article->find('list');
		$tags = $this->ArticlesTag->Tag->find('list');
		$this->set(compact('articles', 'tags'));
	}

	function delete($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid id for ArticlesTag', true));
			$this->redirect(array('action'=>'index'));
		}
		if ($this->ArticlesTag->del($id)) {
			$this->Session->setFlash(sprintf(__('The %s has been deleted.', true), __('Tag',true)));
			$this->redirect(array('action'=>'index'));
		}
	}

}
?>